import { requestClient } from '#/api/request';

export namespace ArticleApi {
  /** 文章列表接口参数 */
  export interface ArticleListParams {
    article_type: number;
    current_page: number;
  }

  /** 文章分类接口返回 */
  export interface ArticleCategory {
    id: number;
    name: string;
  }

  /** 文章信息接口 */
  export interface ArticleInfo {
    id: number;
    article_title: string;
    article_content: string;
    article_type: string;
    publish_time: string;
    current_page: number;
    total_page: number;
  }
}

/**
 * 获取文章列表
 */
export function getArticleListApi(params: ArticleApi.ArticleListParams) {
  return requestClient.post<ArticleApi.ArticleInfo[]>(
    '/v1/get/article/',
    params,
  );
}

/**
 * 获取文章分类
 */
export function getArticleCategoriesApi() {
  return requestClient.post<ArticleApi.ArticleCategory[]>(
    '/v1/get/article/category/',
  );
}
